#coding=utf-8
from uliweb.orm import *
from uliweb.utils.common import get_var

class Selfdev(Model):
    __verbose_name__ = u'自主研发'
    
    system = Reference('system', verbose_name='系统', required=True, collection_name='sys_selfdev')
    kfzx = Reference('kfzx', verbose_name='开发中心', required=True, collection_name='kfzx_selfdev')
    qualified_year  = Field(str, verbose_name='达标年度', max_length=4)
    qualified_type  = Field(str, verbose_name='达标研发类型', max_length=2)
    complexity = Field(float,verbose_name='系统复杂度')
    independent_lastyear = Field(float,verbose_name='上年底自主率')
    independent_thisyear = Field(float,verbose_name='本年底目标自主率')
    independent_destination = Field(float,verbose_name='最终目标自主率')
                
class Selfdev_zx(Model):
    __verbose_name__ = u'中心自主研发率'
    
    kfzx = Reference('kfzx', verbose_name='开发中心', required=True)
    initial = Field(float,verbose_name='初始自主率')
    lastyear = Field(float,verbose_name='上年期末自主率')    
    thisyear = Field(float,verbose_name='本年度目标自主率')
    destination = Field(float,verbose_name='最终目标自主率')

class Selfdev_if_details(Model):
    __verbose_name__ = u'是否参与系统自主率考核设置明细'
    
    requirement =  Reference('requirement', verbose_name='所属准开发需求')
    system =  Reference('system', verbose_name='所属系统')
    task =  Reference('tasks_develop', verbose_name='所属任务')
    user =  Reference('user', verbose_name='设置人')
    created_date = Field(datetime.datetime, verbose_name='设置时间', auto_now_add=True)
    selfdev_if = Field(bool, verbose_name='是否参与系统自主率考核')
    
    class Table:
        fields = [
            {'name':'requirement', 'width':160},
            {'name':'task', 'width':160},
            {'name':'system', 'width':80},
            {'name':'selfdev_if', 'width':80},
            {'name':'created_date', 'width':130},
            {'name':'user', 'width':90},
            ]
    